package com.cjkj.system.api.factory;

import com.cjkj.common.core.domain.R;
import com.cjkj.system.api.RemoteTJ02DataService;
import com.cjkj.system.api.domain.APISmartBraceletData;
import com.cjkj.system.api.domain.SmartBraceletRecords;
import com.cjkj.system.api.domain.request.BraceletHistoryDataReq;
import com.cjkj.system.api.domain.request.LatestDatasReq;
import com.cjkj.system.api.domain.request.PatientEquipmentRTDReq;
import com.cjkj.system.api.domain.request.RecordsReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class RemoteTJ02DataServiceFallbackFactory implements FallbackFactory<RemoteTJ02DataService> {

    @Override
    public RemoteTJ02DataService create(Throwable cause) {
        log.error("系统服务调用失败:{}", cause.getMessage());

        return new RemoteTJ02DataService() {
            @Override
            public R<SmartBraceletRecords> listSmartBraceletRecords(RecordsReq req, String source) {
                return R.fail("获取设备监测数据失败！");
            }

            @Override
            public R<APISmartBraceletData> getLastBraceletDataInUse(PatientEquipmentRTDReq req, String source) {
                return R.fail(req.getEquipmentNo() + "获取最新数据失败！");
            }

            @Override
            public R<Object> reqBraceletHistoryData(BraceletHistoryDataReq req, String source) {
                return R.fail("获取历史记录出错！");
            }

            @Override
            public R<List<APISmartBraceletData>> getLatestDatas(LatestDatasReq req, String source) {
                return R.fail(req.getEquipmentNo() + "获取数据失败！");
            }
        };
    }

}
